<%--
  Created by IntelliJ IDEA.
  User: 邱华英
  Date: 2022/9/22
  Time: 19:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.List"%>
<%@page import="java.util.Map"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<html>
<head>

    <title>个人借阅记录表</title>
    <style type="text/css">
        .fengye{
            border: 1px solid;
            display: inline;
            padding: 8px 16px;
        }
        .hide{
            display: none;
        }
        .c1{
            position: fixed;
            top:0;
            bottom: 0;
            left:0;
            right: 0;
            background: rgba(0,0,0,.5);
            z-index: 2;
        }
        .c2{
            background-color: white;
            position: fixed;
            width: 380px;
            height: 280px;
            top: 50%;
            left: 50%;
            z-index: 3;
            margin-top: -150px;
            margin-left: -200px;
            text-align: center;
            font-size: 15px
        }
        #borrowTable{
            text-align: center;
            border: 1px solid black;
        }
        span{
            color: aliceblue;
        }
        table{

            width: 980px;
        }


        td{

            overflow: hidden;

        }

        #ab{
            width: 50%;
        }
        #fff{
            float: left;
            margin-left: 50px;
            width:693px;
            height: 44px;
            border: 1px solid black;
            position: relative;
        }

        #sss {
            float: left;
            height: 41px;
            width: 100px;
            text-align: center;
        }

        #ttt {
            float: left;
            width: 510px;
            height: 41px;
            padding-left: 10px;
            line-height: 41px;
        }

        #iii {
            /* float: right; */
            position: absolute;
            top: 0;
            left: 611px;
            width: 80px;
            height: 41px;
            background-color: #2d241d;
            font-size: 16px;
            color: #fff;
        }


    </style>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/css/common.css">
    <link rel="stylesheet" href="/css/index.css">
    <link rel="stylesheet" href="/css/booksearch.css">
    <link rel="stylesheet" href="/css/readeradmin.css">
    <title>个人借阅记录表</title>
</head>
<body>

    <%
        String contextPath = request.getSession().getServletContext().getContextPath();
    %>
    <section class="shortcut">
        <div class="w">
            <div class="fl">
                <ul>
                    <li>图书管理系统！&nbsp;</li>
                    <li>
                        <a href="<%=contextPath%>/user/">退出</a>
                        <a href="#" class="style-red">请登录</a>
                    </li>
                </ul>
            </div>
            <div class="fr">
                <ul>


                    <li class="arrow-icon"><a href="aindex.html">联系管理员</a> </li>
                    <li>|</li>
                    <li class="arrow-icon"> <a href="login.html">关于图书馆</a></li>
                </ul>
            </div>
        </div>
    </section>
    <header class="header w">
        <!-- logo -->
        <div class="logo">
            <h1>
                <a href="index.html" title="图书管理系统">人类进步的阶梯</a>
            </h1>
        </div>



    </header>
    <nav class="nav">
        <div class="w">

            <div class="dropdown">
                <div class="dt"> <a href="index.html">首页</a> </div>
                <div class="dd">
                    <ul>
                        <li><a href="<%=contextPath%>/user/library/">图书馆</a> </li>

                        <li><a href="<%=contextPath%>/user/collect/">我的收藏</a> </li>
                        <li><a href="<%=contextPath%>/user/borrow/">我的借阅</a> </li>
                        <li><a href="<%=contextPath%>/user/personCenter/">我的信息</a> </li>
                        <li><a href="<%=contextPath%>/user/inform/all/">通知</a> </li>

                    </ul>
                </div>
            </div>
        </div>
    </nav>
    <div class="w">
        <div class="main">
            <table  id="mainTable" align="center " border="1 " cellpadding="1px " cellspacing="2px " width="980px "  ;>
                <thead class="biaoge ">
                <tr>
                    <th>借阅编号</th>
                    <th>图书编号</th>
                    <th>书名</th>
                    <th>借阅时间</th>
                    <th>应当归还时间</th>
                    <th>实际归还时间</th>
                    <th>超时归还时间</th>
                    <th>续借时间</th>
                    <th>是否归还</th>
                    <th>操作1</th>
                    <th>操作2</th>
                </tr>
                </thead>



<%--            <a href="<%=contextPath%>/user/">退出</a>--%>

<%--    <table border="1px solid">--%>
<%--        <th>借阅编号</th>--%>
<%--        <th>图书编号</th>--%>
<%--        <th>书名</th>--%>
<%--        <th>借阅时间</th>--%>
<%--        <th>应当归还时间</th>--%>
<%--        <th>实际归还时间</th>--%>
<%--        <th>超时归还时间</th>--%>
<%--        <th>续借时间</th>--%>
<%--        <th>是否归还</th>--%>
<%--        <th>操作1</th>--%>
<%--        <th>操作2</th>--%>

        <%
            List<Map<String,Object>> borrows = (List<Map<String, Object>>) request.getAttribute("borrows");
            if(borrows != null){
            for(int i = 0;i < borrows.size();i++){
                Map<String,Object> borrow = borrows.get(i);

        %>
        <tr>
            <th><%=borrow.get("borrid")%></th>
            <td><%=borrow.get("id")%></td>
            <td><%=borrow.get("bName")%></td>
            <td><%=borrow.get("borrowTime")%></td>
            <td><%=borrow.get("returnTime")%></td>
            <td><%=borrow.get("reallyTime")%></td>
            <td><%=borrow.get("overTime")%></td>
            <td><%=borrow.get("xujieTime")%></td>
            <td><%=borrow.get("isreturn")%></td>
            <td class="returnBook">还书</td>
            <td class="xujie">续借</td>
        </tr>
        <%}%>
        <%}%>
    </table>
    <br><br>
    <li class="fengye"><a onclick="deleteYeshu()"><<</a></li>
    <li class="fengye">第<label name="yeshu" id="yeshu">${yeshu}</label>页</li>
    <li class="fengye"><a onclick="addYeshu()">>></a></li>

    <div id="shade" class="c1 hide"></div>
    <div id="modal" class="c2 hide">
        <form>
            <h2>续借表</h2>
            <lable>借阅编号:</lable><input type="text" readonly="true" class="borrid"><br>
            <lable>图书编号:</lable><input type="text" readonly="true" class="bookid"><br>
            <lable>书名:</lable><input type="text" readonly="true" class="bookName"><br>
            <lable>借阅时间:</lable><input type="date" readonly="true" class="borrowTime"><br>
            <lable>应当归还时间:</lable><input type="date" readonly="true" class="returnTime"><br>
            <lable>超时时间:</lable><input type="text" readonly="true" class="overTime"><br>
            <lable>续借时间:</lable><input type="date" class="xujieTime"><br><br>
            <input id="submit"value="确定续借" type="button"></input> <input type="button" value="取消" id="quit"></input>
        </form>
    </div>
        </div>
        <div class="w">
            <div class="minyan">

                六经三史，诸子百家，非无可观，皆是为治。

            </div>

        </div>
    </div>
</body>

<script type="text/javascript">
    $(function () {
        $(".returnBook").click(function () {
            var borrid = this.parentNode.children[0].innerHTML;
            var bookid = this.parentNode.children[1].innerHTML;
            var isreturn = this.parentNode.children[8].innerHTML;
            if(isreturn=="true"){
                alert("已经归还")
            }else{
                $.ajax({
                    type: "post",
                    url: "../return",
                    data: {
                        "borrid": borrid,
                        "bookid": bookid,
                    },
                    success: function (msg) {
                        if (msg == true) {
                            alert("归还成功！")
                        } else {
                            alert("归还失败")
                        }
                    }
                })
            }

        })
    })

    $(function (){
        $(".xujie").click(function (){
            $(".borrid").val(this.parentNode.children[0].innerHTML);
            $(".bookid").val(this.parentNode.children[1].innerHTML);
            $(".bookName").val(this.parentNode.children[2].innerHTML);
            $(".borrowTime").val(this.parentNode.children[3].innerHTML);
            $(".returnTime").val(this.parentNode.children[4].innerHTML);
            $(".overTime").val(this.parentNode.children[6].innerHTML);
            $(".xujieTimeTime").val(this.parentNode.children[7].innerHTML);
            $("#shade").show();
            $("#modal").show();
        })
    })

    $(function (){
        $("#quit").click(function (){
            $("#shade").hide();
            $("#modal").hide();
        })
    })

    $(function (){
        $("#submit").click(function (){
            var borrid=$(".borrid").val();
            var bookid=$(".bookid").val();
            var xujieTime=$(".xujieTime").val();

            $.ajax({
                type:"post",
                url:"../xujie",
                data: {
                    "borrid":borrid,
                    "bookid":bookid,
                    "xujieTime":xujieTime,
                },
                success(msg){
                    if(msg==true){
                        alert("续借成功！")
                    }else{
                        alert("续借失败")
                    }
                }
            })
        })
    })

    <%--<a href="personBorrowServlet?task=xujieBook&borrid=<%=borrow.get("borrid")%>&bookid=<%=borrow.get("id")%>">续借</a>--%>
    function addYeshu(){
        var yeshu1 = document.getElementById("yeshu");
        window.location.href="<%=contextPath%>/user/borrow/search/add?yeshu="+yeshu1.innerText;
    }
    function deleteYeshu(){
        var yeshu1 = document.getElementById("yeshu");
        window.location.href="<%=contextPath%>/user/borrow/search/delete?yeshu="+yeshu1.innerText;
    }

</script>

</html>
